
*Do file submitted to University of Laval 
*Measuring and Alleviating Poverty and Inequality (ECN-6992)
*Professors: Luca Tiberti and Jean Louis Bago
***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

//Beginning of Poverty Profile //
use "C:\Windows\system32\config\systemprofile\Desktop\Course Laval\Essay\Ethiopia13_\hh_final 2013.dta" 
**the original Welfare measure is adjusted for  adult equivalence and deflated to reference period 2011
**Of the three equivalence procedure i am forced to use square root of household size. Since the unique household identifier
*available in the data is not exactlly unique, square root approach is prefered

*use hh_final 2013
gen ae= hhsize^0.5
gen pcexp_ae=hhexp/ae
gen pcinc_ae=totinc/ae
*Consumer price index deflator is used to adjust the welfare measures of 2013 to the national poverty line reference period of 2011
gen rpcexp_ae=0.7454*pcexp_ae
clear

*use hh_final 2015
gen ae= hhsize^0.5
gen pcexp_ae=hhexp/ae
gen pcinc_ae=totinc/ae
*Consumer price index deflator is used to adjust the welfare measures of 2015 to the national poverty line reference period of 2011
gen rpcexp_ae=0.6303*pcexp_ae
clear

***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

//Begining of Table 2:Poverty Profile 2013//   
*use hh_final 2013
_daspmenu
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)

ifgt rpcexp_ae, alpha(0) hsize(hhsize) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) pline(3781)


//Poverty status by urban/rural 2013//

ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(urban) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(urban) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(urban) pline(3781)

//Poverty status by gender of household head 2013//

ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(femhead) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(femhead) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(femhead) pline(3781)

//Poverty status by age of household head 2013//

gen agegroup=1 if agehead>=15 & agehead<=29
replace agegroup=2 if agehead>=30 & agehead<=60
replace agegroup=3 if agehead>60
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(agegroup) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(agegroup) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(agegroup) pline(3781)

//Poverty status by size of household 2013//

gen hhgroup=1 if hhsize<=5
replace hhgroup=2 if hhsize>5
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(hhgroup) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(hhgroup) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(hhgroup) pline(3781)

//Poverty status by labour force presence in the hh 2013//

gen nlabor=0 if hhlabor<1
replace nlabor=1 if hhlabor==1
replace nlabor=2 if hhlabor>1
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(nlabor) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(nlabor) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(nlabor) pline(3781)

//Poverty status by tenure status(house ownership) 2013//

ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(ownhome) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(ownhome) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(ownhome) pline(3781)


//Poverty status by access to social assistance 2013//
gen socass=1 if soc_ass>0
recode socass .=0
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(socass) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(socass) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(socass) pline(3781)

//Poverty status by access to road 2013//
gen onroad=1 if distroad==0
recode onroad .=0
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(onroad) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(onroad) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(onroad) pline(3781)

//Poverty status by access to electricity 2013//
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(electricity) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(electricity) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(electricity) pline(3781)


//Poverty status by access to credit 2013//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(creditdummy) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(creditdummy) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(creditdummy) pline(3781)


//Rural Poverty status by acccess to irrigation 2013//
keep if urban==0
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(irrigation) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(irrigation) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(irrigation) pline(3781)

//Rural Poverty status by acccess to improved seed 2013//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(impseedsdummy) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(impseedsdummy) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(impseedsdummy) pline(3781)

//Rural Poverty status by acccess to inorganic fertilizer 2013//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(infertdummy) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(infertdummy) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(infertdummy) pline(3781)

//Rural Poverty status by acccess to training/agri extension 2013//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(dtrain_ext_agr) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(dtrain_ext_agr) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(dtrain_ext_agr) pline(3781)

**End of table 2**

*** end of 2013 poverty profile***
************************************************************************************
************************************************************************************

//Beginning of Table 3:Poverty Profile 2015// 
clear
*use hh_final 2015
_daspmenu
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
//Poverty status at country level 2015//
ifgt rpcexp_ae, alpha(0) hsize(hhsize) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) pline(3781)

//Poverty status by urban/rural 2015//
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(urban) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(urban) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(urban) pline(3781)

//Poverty status by gender of household head 2015//
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(femhead) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(femhead) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(femhead) pline(3781)

//Poverty status by age of household head 2015//
gen agegroup=1 if agehead>=15 & agehead<=29
replace agegroup=2 if agehead>=30 & agehead<=60
replace agegroup=3 if agehead>60
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(agegroup) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(agegroup) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(agegroup) pline(3781)

//Poverty status by size of household 2015//
gen hhgroup=1 if hhsize<=5
replace hhgroup=2 if hhsize>5
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(hhgroup) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(hhgroup) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(hhgroup) pline(3781)

//Poverty status by labour force presence in the hh 2015//
gen nlabor=0 if hhlabor<1
replace nlabor=1 if hhlabor==1
replace nlabor=2 if hhlabor>1
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(nlabor) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(nlabor) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(nlabor) pline(3781)

//Poverty status by tenure status(house ownership) 2015//
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(ownhome) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(ownhome) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(ownhome) pline(3781)


//Poverty status by access to social assistance 2015//
gen socass=1 if soc_ass>0
recode socass .=0
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(socass) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(socass) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(socass) pline(3781)

//Poverty status by access to road 2015//
gen onroad=1 if distroad==0
recode onroad .=0
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(onroad) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(onroad) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(onroad) pline(3781)

//Poverty status by access to electricity 2015//
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(electricity) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(electricity) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(electricity) pline(3781)


//Poverty status by access to electricity 2015//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(creditdummy) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(creditdummy) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(creditdummy) pline(3781)


//Rural Poverty status by acccess to irrigation 2015//
keep if urban==0
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(irrigation) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(irrigation) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(irrigation) pline(3781)

//Rural Poverty status by acccess to improved seed 2015//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(impseedsdummy) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(impseedsdummy) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(impseedsdummy) pline(3781)

//Rural Poverty status by acccess to inorganic fertilizer 2015//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(infertdummy) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(infertdummy) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(infertdummy) pline(3781)

//Rural Poverty status by acccess to training/agri extension 2015//
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
ifgt rpcexp_ae, alpha(0) hsize(hhsize) hgroup(dtrain_ext_agr) pline(3781)
ifgt rpcexp_ae, alpha(1) hsize(hhsize) hgroup(dtrain_ext_agr) pline(3781)
ifgt rpcexp_ae, alpha(2) hsize(hhsize) hgroup(dtrain_ext_agr) pline(3781)

**End of Table 3**
*** end of 2015 poverty profile***

***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

//Figure 1:Cummulative poverty gap curve Rural/Urban 2013// 
clear
*use hh_final 2013
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
label define urban 0 "Rural" 1 "Urban"
label values urban urban
cpoverty rpcexp_ae, hsize(hhsize) hgroup(urban) curve(cpg) pline(3781) min(0) max(1)
***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

//Figure 2:Cummulative poverty gap curve Rural/Urban 2015// 
clear
*use hh_final 2015
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
label define urban 0 "Rural" 1 "Urban"
label values urban urban
cpoverty rpcexp_ae, hsize(hhsize) hgroup(urban) curve(cpg) pline(3781) min(0) max(1)
***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

// Inequality analysis 2013//
*Figure 3:Lorenz curve 2013 Rural/urban*
clear
*use hh_final 2013
label define urban 0 "Rural" 1 "Urban"
label values urban urban
clorenz rpcexp_ae, hsize(hhsize) hgroup(urban) pop(no)
***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

*Figure 4:Lorenz curve 2015 Rural/urban*
clear
*use hh_final 2015
label define urban 0 "Rural" 1 "Urban"
label values urban urban
clorenz rpcexp_ae, hsize(hhsize) hgroup(urban) pop(no)

***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  


// Table 4 beginning :Factor decompose Gini coefficient for 2013//
clear
*use hh_final 2013
sgini rpcexp_ae [aw=expfact],param(1.5 2 2.5)
bys urban:sgini rpcexp_ae [aw=expfact] , param(1.5 2 2.5)

//Factor decomposed Gini coefficient for 2015//
clear
*use hh_final 2015
sgini rpcexp_ae [aw=expfact],param(1.5 2 2.5)
bys urban:sgini rpcexp_ae [aw=expfact] , param(1.5 2 2.5)

//Atkinson Index 2013 for e=0.5,1.0 and 1.5//
clear
*use hh_final 2013
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
iatkinson rpcexp_ae, epsilon(0.5) hsize(hhsize) hgroup(urban)
iatkinson rpcexp_ae, epsilon(1.0) hsize(hhsize) hgroup(urban)
iatkinson rpcexp_ae, epsilon(2.0) hsize(hhsize) hgroup(urban)

//Atkinson Index 2015 for e=0.5,1.0 and 1.5//
clear
*use hh_final 2015
svyset psu [pweight=weight_hh], strata(region) vce(linearized) singleunit(missing)
iatkinson rpcexp_ae, epsilon(0.5) hsize(hhsize) hgroup(urban)
iatkinson rpcexp_ae, epsilon(1.0) hsize(hhsize) hgroup(urban)
iatkinson rpcexp_ae, epsilon(2.0) hsize(hhsize) hgroup(urban)

**Table 4 end**

***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

**Table5 beginning:
// Inequality difference  between 2013 and 2015 //
*use hh_final 2013 and 2015
digini rpcexp_ae rpcexp_ae, hsize1(hhsize) file2(C:\Windows\system32\config\systemprofile\Desktop\Course Laval\Essay\Ethiopia13_\hh_final 2015.dta) hsize2(hhsize)
//Rural inequality difference  between 2013 and 2015 //
*use hh_final 2013 and 2015
digini rpcexp_ae rpcexp_ae, hsize1(hhsize) cond1(urban==0 ) file2(C:\Windows\system32\config\systemprofile\Desktop\Course Laval\Essay\Ethiopia13_\hh_final 2015.dta) hsize2(hhsize) cond2(urban==0 )

//Urban inequality difference  between 2013 and 2015//
*use hh_final 2013 and 2015
digini rpcexp_ae rpcexp_ae, hsize1(hhsize) cond1(urban==1 ) file2(C:\Windows\system32\config\systemprofile\Desktop\Course Laval\Essay\Ethiopia13_\hh_final 2015.dta) hsize2(hhsize) cond2(urban==1 )
**Table 5 ending**

***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

**Table 6 Begining**
****Beginning logit regression***
*use hh_final 2013
gen poor=1 if rpcexp_ae<3781
recode poor .=0
save "C:\Windows\system32\config\systemprofile\Desktop\Course Laval\Essay\Ethiopia13_\hh_final 2013.dta", replace

*use hh_final 2015
gen poor=1 if rpcexp_ae<3781
recode poor .=0
save "C:\Windows\system32\config\systemprofile\Desktop\Course Laval\Essay\Ethiopia13_\hh_final 2015.dta", replace

***Logit Regression Result of Poverty and its determinants for the overall year2013***
clear
*use hh_final 2013
logit poor urban  toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc
outreg2 using  out.doc
 
 ***Logistic Regression Result of Poverty and its determinants for the  urban observation overall year 2015***
clear
*use hh_final 2015
logit poor urban toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc 
outreg2 using out.doc,append
 
 ***Logistic Regression Result of Poverty and its determinants for the rural observation year 2013***
 clear
*use hh_final 2013
logit poor toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc irrigation impseedsdummy infertdummy dtrain_ext_agr if urban==0
outreg2  using out.doc,append

 ***Logistic Regression Result of Poverty and its determinants for the rural observation year 2015***
clear
*use hh_final 2015
logit poor toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc irrigation impseedsdummy infertdummy dtrain_ext_agr if urban==0
outreg2 using out.doc,append
shellout using `"out.doc"'
**Table 6 ending**
***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  

 
**Table 7 Begining**
 //For 2013 dataset
*use hh_final 2013
gen lnrpcexp_ae =ln(rpcexp_ae)

reg lnrpcexp_ae urban toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc
outreg2 using output.doc
sqreg lnrpcexp_ae urban toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc, quantile(0.25,0.50,0.75) reps(100)
outreg2 using output.doc,append
shellout using `"output.doc"'
**Table 7 ending**

**Appendix I**
//Graphical presentation of OLS and quantile estimates 2013//
quietly qreg lnrpcexp_ae urban toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc
grqreg, cons ci ols olsci
***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  


**Table 8 Begining**
//For 2015 dataset
*use hh_final 2015
gen lnrpcexp_ae=ln(rpcexp_ae)
reg lnrpcexp_ae urban toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc
outreg2 using output2.doc
sqreg lnrpcexp_ae urban toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc, quantile(0.25,0.50,0.75) reps(100)
outreg2 using output2.doc,append
shellout using `"output2.doc"'
**Table 8 Begining**

**Appendix I**
//Graphical presentation of OLS and quantile estimates 2015//
quietly qreg lnrpcexp_ae urban toilet int_rem electricity femhead educhead credit hhsize ownhome agehead hhlabor soc_ass pcinc
grqreg, cons ci ols olsci
***********************************************************************************************************************************************************************************  
***********************************************************************************************************************************************************************************  



************End of the dofile************
            ***Thank You***
 
 

